package datas
{
	import main.DataSubBase;
	
	import struct.Weather;
	
	public class WeatherData extends DataSubBase
	{
		private var weatherInfo:Object;
		private var weatherList:Array;
		
		private var currentDate:Date;
		
		public function WeatherData()
		{
			weatherInfo = null;
			weatherList = [];
			
			currentDate = new Date;
		}
		
		public function setWeather(obj:Object):void
		{
			weatherInfo = obj;
			changeWeatherInfo();
		}
		
		private function changeWeatherInfo():void
		{
			var weatherObj:Weather;
			for(var i:int = 1;i < 6;i++){
				weatherObj = new Weather;
				weatherObj.city = weatherInfo.weatherinfo.city;
				weatherObj.date = (currentDate.time + 86400000 * (i - 1)) / 1000;
				weatherObj.info = weatherInfo.weatherinfo["weather" + i];
				weatherObj.temp = weatherInfo.weatherinfo["temp" + i];
				weatherObj.wind = weatherInfo.weatherinfo["wind" + i];
				weatherObj.suggest = weatherInfo.weatherinfo["index_d"];
				weatherObj.imgUrl1 = weatherInfo.weatherinfo["img" + ((i - 1) * 2 + 1)];
				weatherObj.imgUrl2 = weatherInfo.weatherinfo["img" + i * 2];
				
				weatherList.push(weatherObj);
			}
		}
		
		public function get weatherInfoList():Array
		{
			return weatherList;
		}
	}
}